using System;
using Contrib.BSCarouselSlide.Models;
using Orchard.ContentManagement;
using Orchard.Environment.Extensions;
using Orchard.Localization;

namespace Contrib.BSCarouselSlide.Tokens {

    public class BSCarouselSlideTokens : ITokenProvider {
        private readonly IContentManager _contentManager;

        public BSCarouselSlideTokens(IContentManager contentManager)
        {
            _contentManager = contentManager;
            T = NullLocalizer.Instance;
        }

        public Localizer T { get; set; }

        public void Describe(dynamic context) {
            context.For("Content", T("Content Items"), T("Content Items"))
                .Token("CarouselKey", T("Carousel Key"), T("The grouping key for queries."))
                .Token("Priority", T("Priority"), T("The Slide Priority."))
                .Token("TextClass", T("Text Class"), T("Css class to use with Text body."))
                .Token("ImageClass", T("Image Class"), T("Css class to use with Image."))

                ;
        }

        public void Evaluate(dynamic context) {
            context.For<IContent>("Content")
                .Token("CarouselKey", (Func<IContent, object>)(content => content.As<BSCarouselSlidePart>().CarouselKey))
                .Token("Priority", (Func<IContent, object>)(content => content.As<BSCarouselSlidePart>().Priority))
                .Token("TextClass", (Func<IContent, object>)(content => content.As<BSCarouselSlidePart>().TextClass))
                .Token("ImageClass", (Func<IContent, object>)(content => content.As<BSCarouselSlidePart>().ImageClass))
                ;
        }
    }
}